package view;


import java.util.Calendar;
import java.util.Date;

import com.squareup.timessquare.CalendarPickerView;
import com.squareup.timessquare.CalendarPickerView.SelectionMode;
import com.example.pruebapfi.*;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;


public class CalendarTimesSquare extends Activity {
	  private CalendarPickerView calendar;

	  @Override
	  protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    setContentView(R.layout.sample_calendar_picker);
	    final Calendar nextYear = Calendar.getInstance();
	    nextYear.add(Calendar.YEAR, 1);

	    final Calendar lastYear = Calendar.getInstance();
	    lastYear.add(Calendar.YEAR, -1);

	    calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
	    calendar.init(lastYear.getTime(), nextYear.getTime()) //
	        .inMode(SelectionMode.SINGLE) //
	        .withSelectedDate(new Date());

	    findViewById(R.id.done_button).setOnClickListener(new OnClickListener() {
	      @Override
	      public void onClick(View view) {
	        Intent returnIntent = new Intent();
	        returnIntent.putExtra("selected_date",calendar.getSelectedDate().getTime());
	        returnIntent.putExtra("fecha",getIntent().getExtras().getString("fecha"));
	        setResult(RESULT_OK,returnIntent);
	        finish();
	      }
	    });
	  }
	}
